--[[ 编码: JX-60-16 名称: 出库波次-强制完成(后台) 作者:HAN 日期:2025-2-20 入口函数: ForceFinish 功能说明: 出库波次 WFP 处理强制完成 更改记录: --]] wms_op = require( "wms_operation" ) wms_cntr = require( "wms_container" ) jx_base = require( "jx_base" ) function ForceFinish ( strLuaDEID ) local nRet, strRetInfo local outbound_wave = {} nRet, outbound_wave = m3.GetSysCurEditDataObj( strLuaDEID, "Outbound_Wave" ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【出库波次】对象属性失败!"..outbound_wave ) end if ( outbound_wave.b_state == 0 or outbound_wave.b_state == 2) then -- 0 未配货 2 -- 配货完成 -- 把出库波次设置为完成,并且关闭数量=出库数量 nRet, strRetInfo = jx_base.Set_Outbound_Wave_Force_Finish( strLuaDEID, outbound_wave.wave_no ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end elseif ( outbound_wave.b_state == 3 or outbound_wave.b_state == 7 or outbound_wave.b_state == 8 ) then -- 3/执行 7/暂停 8/关闭中 -- 判断这个出库波次的作业是否还有在执行中的,如果有就不能马上关闭,只能设置为关闭中,等执行中的作业完成后才能设置为关闭,这个另外程序来处理 -- 判断是否有存在正在执行的作业 N_B_STATE = 1 strCondition = "S_BS_TYPE = 'Outbound_Wave' AND S_BS_NO = '"..outbound_wave.wave_no.."' AND N_B_STATE = 1" nRet, strRetInfo = mobox.existThisData( strLuaDEID, "Operation", strCondition ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end if ( strRetInfo == "yes" ) then -- 存在正在执行的作业 strCondition = "S_WAVE_NO = '"..outbound_wave.wave_no.."'" strUpdateSql = "N_B_STATE = 8 " -- 关闭中 nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Outbound_Wave", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【出库波次】信息失败!"..strRetInfo ) end else -- 已经没有正在执行的作业 nRet, strRetInfo = jx_base.Set_Outbound_Wave_Force_Finish( strLuaDEID, outbound_wave.wave_no ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end end -- 把作业状态 = 等待,等待前 的作业状态设置为 取消 strCondition = "S_BS_TYPE = 'Outbound_Wave' AND S_BS_NO = '"..outbound_wave.wave_no.."' AND ( N_B_STATE = 0 or N_B_STATE = 6 or N_B_STATE = 8 )" strUpdateSql = "N_B_STATE = 7 " nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Operation", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【作业】信息失败!"..strRetInfo ) end end end